package com.ljc.dao;

import com.ljc.dto.DeviceArgumentResult;
import com.ljc.entity.DeviceArgumentGather;
import com.ljc.vo.ArgumentData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.security.PrivateKey;
import java.util.List;

@Repository
@Mapper
public interface DeviceArgumentGatherDao {
    @Insert("insert into device_argument_gather(device_purchase_planning_id) " +
            "values(#{devicePurchasePlanningId})")
    void add(int devicePurchasePlanningId);

    @Select("select p.*,a.id  aid,a.status,a.result from  device_purchase_planning p left join  device_argument_gather a  on  p.id=a.device_purchase_planning_id\n" +
            "where p.project_planning_id=#{projectId}")
    List<DeviceArgumentResult> findByProjectId(int projectId);



    //update
    @Update("update device_argument_gather " +
            "set opinion=#{opinion},operator=#{operator},result=#{result},date=#{date},status=2 " +
            "where device_purchase_planning_id=#{devicePurchasePlanningId}")
    void updateArgument(ArgumentData argumentData);

    @Select("select * from device_argument_gather" +
            " where device_purchase_planning_id=#{id}")
    DeviceArgumentGather selectOne(int id);

}
